package cn.com.headfree.mouldshow.dao.impl;

import cn.com.headfree.entity.TStandInfoTemp;
import cn.com.headfree.mouldshow.dao.TStandInfoTempDao;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Repository("/tStandInfoTempDao")
public class TStandInfoTempDaoImpl extends BaseDaoImpl<TStandInfoTemp> implements TStandInfoTempDao {


    @Override
    public void saveInfo(TStandInfoTemp tStandInfo) {
        String sql = "insert into t_stand_info_temp (id,issue_time,name,type,level,org_id,creater_id,creater_name,create_time,updater_id,updater_name,update_time,del_sign,is_valid,audit_state,orignal_id,business_type_id,primitive_id) values ";
        StringBuilder sqlBuilder = new StringBuilder(sql);
        sqlBuilder.append("(#{id,jdbcType=VARCHAR},").append("#{issue_time,jdbcType=DATE},")
                .append("#{name,jdbcType=VARCHAR},").append("#{type,jdbcType=VARCHAR},")
                .append("#{level,jdbcType=VARCHAR},").append("#{org_id,jdbcType=VARCHAR},").append("#{creater_id,jdbcType=VARCHAR},")
                .append("#{creater_name,jdbcType=VARCHAR},").append("#{create_time,jdbcType=DATE},")
                .append("#{updater_id,jdbcType=VARCHAR},").append("#{updater_name,jdbcType=VARCHAR},")
                .append("#{update_time,jdbcType=DATE},").append("#{del_sign,jdbcType=INTEGER},")
                .append("#{is_valid,jdbcType=INTEGER},").append("#{audit_state,jdbcType=INTEGER},")
                .append("#{orignal_id,jdbcType=VARCHAR},").append("#{business_type_id,jdbcType=VARCHAR},")
                .append("#{primitive_id,jdbcType=VARCHAR})");
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", tStandInfo.getId());
        params.put("issue_time", tStandInfo.getIssueTime());
        params.put("name", tStandInfo.getName());
        params.put("type", tStandInfo.getType());
        params.put("level", tStandInfo.getLevel());
        params.put("org_id", tStandInfo.getOrgId());
        params.put("creater_id", tStandInfo.getCreaterId());
        params.put("creater_name", tStandInfo.getCreaterName());
        params.put("create_time", new Timestamp(new Date().getTime()));
        params.put("updater_id", tStandInfo.getUpdaterId());
        params.put("updater_name", tStandInfo.getUpdaterName());
        params.put("update_time", new Timestamp(new Date().getTime()));
        params.put("del_sign", 0);
        params.put("is_valid", tStandInfo.getIsValid());
        params.put("audit_state", tStandInfo.getAuditState());
        params.put("orignal_id", tStandInfo.getOrignalId());
        params.put("business_type_id", tStandInfo.getBusinessTypeId());
        params.put("primitive_id", tStandInfo.getPrimitiveId());
        this.executeSql(sqlBuilder.toString(), params);
    }
}
